{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="wap.php"><i class="return"></i></a>
	<div class="titleView">体验店</div>
</div>

<div class="shop-index main-padding-top">
	<div class="pullRefresh">
		<ul class="list">
			{foreach from=$data name=g item=g}
			<li>
				<a class="scale" href="wap.php?app=shop&act=detail&shop_id={$g->id}">
					<div class="view">
						<div><tt>{$g->city}</tt>-{$g->name}</div>
						<ul>
							<li><i></i><span>{$g->mobile}</span></li>
							<li><i></i><span class="address" province="{$g->province}" city="{$g->city}" district="{$g->district}" address="{$g->address}"></span></li>
						</ul>
					</div>
					<div class="pic" style="background-image:url({$g->poster_pic});"></div>
				</a>
			</li>
			{/foreach}
		</ul>
	</div>
</div>

{include file="footer.html"}
<script type="text/javascript" src="js/city.js"></script>
<script>
var offset = $('.pullRefresh .list > li').length;
function createHtml(g){
	var html = '<li>\
		<a class="scale" href="wap.php?app=shop&act=detail&shop_id='+g.id+'">\
			<div class="view">\
				<div><tt>'+g.city+'</tt>-'+g.name+'</div>\
				<ul>\
					<li><i></i><span>'+g.mobile+'</span></li>\
					<li><i></i><span class="address" province="'+g.province+'" city="'+g.city+'" district="'+g.district+'" address="'+g.address+'"></span></li>\
				</ul>\
			</div>\
			<div class="pic" style="background-image:url('+g.poster_pic+');"></div>\
		</a>\
	</li>';
	offset++;
	return html;
}
function changeCityCode(){
	$('tt').each(function(){
		var html = $(this).html();
		if(isNaN(html))return true;
		$(this).html(getCityName(html).replace(/市/g, ''));
	});
	$('span.address').each(function(){
		var _this = $(this), province = _this.attr('province'), city = _this.attr('city'), district = _this.attr('district'), address = _this.attr('address');
		_this.html(comboCity(province, city, district, address));
	});
}
$(function(){
	$('.shop-index').height($.window().height-$('.shop-index').padding().top);
	changeCityCode();
	$('.pullRefresh').pullRefresh({
		header : true,
		footer : true,
		footerNoMoreText : '- END -',
		refresh : function(fn){
			var _this = this;
			offset = 0;
			$.getJSON('api.php?app=shop&act=index', function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data))for(var i=0; i<json.data.length; i++)html += createHtml(json.data[i]);
				_this.find('.list').html(html);
				changeCityCode();
				fn();
			});
		},
		load : function(fn){
			var _this = this;
			$.getJSON('api.php?app=shop&act=index', { offset:offset }, function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data))for(var i=0; i<json.data.length; i++)html += createHtml(json.data[i]);
				_this.find('.list').append(html);
				changeCityCode();
				fn();
			});
		}
	});
});
</script>